package com.yc.biz.impl;

import java.util.ArrayList;
import java.util.List;

import com.yc.bean.User;
import com.yc.biz.UserBiz;
import com.yc.dao.DBHelper;

public class UserBizImpl implements UserBiz {
	DBHelper db = new DBHelper();

	@Override
	public User login(String nickname, String pwd) {
		String sql="select * from memberinfo where nickname=? and pwd=?";
		List<Object> params=new ArrayList<Object>();
		params.add(nickname);
		params.add(pwd);
		List<User> list=db.find(sql, params, User.class);
		
		if( list.size()<=0 ){
			return null;
		}else{
			return list.get(0);
		}
		
	}

	@Override
	public int reg(String rnickname, String rpwd) {
		String sql="insert into memberinfo values(null,?,?,0)";
		List<Object> params = new ArrayList<Object>();
		params.add(rnickname);
		params.add(rpwd);
		
		return db.doUpdate(sql, params);
	}

}
